{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Tokenization"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "lines = [\n",
    "    'How to tokenize?\\nLike a boss.',\n",
    "    'Google is accessible via http://www.google.com',\n",
    "    '1000 new followers! #TwitterFamous',\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['How to tokenize?\\nLike a boss.',\n",
       " 'Google is accessible via http://www.google.com',\n",
       " '1000 new followers! #TwitterFamous']"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "lines"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['How', 'to', 'tokenize?', 'Like', 'a', 'boss.']\n",
      "['Google', 'is', 'accessible', 'via', 'http://www.google.com']\n",
      "['1000', 'new', 'followers!', '#TwitterFamous']\n"
     ]
    }
   ],
   "source": [
    "for line in lines:\n",
    "    print(line.split())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['How', 'to', 'tokenize', 'Like', 'a', 'boss']\n",
      "['Google', 'is', 'accessible', 'via', 'http', 'www', 'google', 'com']\n",
      "['1000', 'new', 'followers', 'TwitterFamous']\n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "\n",
    "_token_pattern = r\"\\w+\"\n",
    "token_pattern = re.compile(_token_pattern)\n",
    "    \n",
    "for line in lines:\n",
    "    print(token_pattern.findall(line))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['how', 'to', 'tokenize', 'like', 'a', 'boss']\n",
      "['google', 'is', 'accessible', 'via', '_url_']\n",
      "['_num_', 'new', 'followers', '_hashtag_']\n"
     ]
    }
   ],
   "source": [
    "_token_pattern = r\"\\w+\"\n",
    "token_pattern = re.compile(_token_pattern)\n",
    "\n",
    "def tokenizer(line):\n",
    "    line = line.lower()\n",
    "    line = re.sub(r'http[s]?://[\\w\\/\\-\\.\\?]+','_url_', line)\n",
    "    line = re.sub(r'\\d+:\\d+','_time_', line)\n",
    "    line = re.sub(r'#\\w+', '_hashtag_', line)\n",
    "    line = re.sub(r'\\d+','_num_', line)\n",
    "    return token_pattern.findall(line)\n",
    "\n",
    "for line in lines:\n",
    "    print(tokenizer(line))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['How', 'to', 'tokenize', 'Like', 'boss']\n",
      "['Google', 'is', 'accessible', 'via', 'http', 'www', 'google', 'com']\n",
      "['1000', 'new', 'followers', 'TwitterFamous']\n"
     ]
    }
   ],
   "source": [
    "import re\n",
    "\n",
    "_token_pattern = r\"(?u)\\b\\w\\w+\\b\"\n",
    "token_pattern = re.compile(_token_pattern)\n",
    "    \n",
    "for line in lines:\n",
    "    print(token_pattern.findall(line))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.feature_extraction.text import CountVectorizer\n",
    "\n",
    "vec = CountVectorizer(lowercase=True, tokenizer=tokenizer)\n",
    "\n",
    "x = vec.fit_transform(lines)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['how', 'to', 'tokenize', 'like', 'boss', 'google', 'is', 'accessible', 'via', '_url_', '_num_', 'new', 'followers', '_hashtag_']\n"
     ]
    }
   ],
   "source": [
    "print(list(vec.vocabulary_.keys()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>_hashtag_</th>\n",
       "      <th>_num_</th>\n",
       "      <th>_url_</th>\n",
       "      <th>accessible</th>\n",
       "      <th>boss</th>\n",
       "      <th>followers</th>\n",
       "      <th>google</th>\n",
       "      <th>how</th>\n",
       "      <th>is</th>\n",
       "      <th>like</th>\n",
       "      <th>new</th>\n",
       "      <th>to</th>\n",
       "      <th>tokenize</th>\n",
       "      <th>via</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>doc-id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        _hashtag_  _num_  _url_  accessible  boss  followers  google  how  is  \\\n",
       "doc-id                                                                          \n",
       "0               0      0      0           0     1          0       0    1   0   \n",
       "1               0      0      1           1     0          0       1    0   1   \n",
       "2               1      1      0           0     0          1       0    0   0   \n",
       "\n",
       "        like  new  to  tokenize  via  \n",
       "doc-id                                \n",
       "0          1    0   1         1    0  \n",
       "1          0    0   0         0    1  \n",
       "2          0    1   0         0    0  "
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.DataFrame(\n",
    "    x.todense(), \n",
    "    columns=vec.get_feature_names(),\n",
    ")\n",
    "\n",
    "df.index.name = 'doc-id'\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "flight_delayed_lines = [\n",
    "    'Flight was delayed, I am not happy',\n",
    "    'Flight was not delayed, I am happy'\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>am</th>\n",
       "      <th>delayed</th>\n",
       "      <th>flight</th>\n",
       "      <th>happy</th>\n",
       "      <th>not</th>\n",
       "      <th>was</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>doc-id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        am  delayed  flight  happy  not  was\n",
       "doc-id                                      \n",
       "0        1        1       1      1    1    1\n",
       "1        1        1       1      1    1    1"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.feature_extraction.text import CountVectorizer\n",
    "\n",
    "vec = CountVectorizer(ngram_range=(1,1))\n",
    "\n",
    "x = vec.fit_transform(flight_delayed_lines)\n",
    "\n",
    "df = pd.DataFrame(\n",
    "    x.todense(), \n",
    "    columns=vec.get_feature_names(),\n",
    ")\n",
    "\n",
    "df.index.name = 'doc-id'\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>am happy</th>\n",
       "      <th>am not</th>\n",
       "      <th>delayed am</th>\n",
       "      <th>flight was</th>\n",
       "      <th>not delayed</th>\n",
       "      <th>not happy</th>\n",
       "      <th>was delayed</th>\n",
       "      <th>was not</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>doc-id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        am happy  am not  delayed am  flight was  not delayed  not happy  \\\n",
       "doc-id                                                                     \n",
       "0              0       1           1           1            0          1   \n",
       "1              1       0           1           1            1          0   \n",
       "\n",
       "        was delayed  was not  \n",
       "doc-id                        \n",
       "0                 1        0  \n",
       "1                 0        1  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.feature_extraction.text import CountVectorizer\n",
    "\n",
    "vec = CountVectorizer(ngram_range=(2,2))\n",
    "\n",
    "x = vec.fit_transform(flight_delayed_lines)\n",
    "\n",
    "df = pd.DataFrame(\n",
    "    x.todense(), \n",
    "    columns=vec.get_feature_names(),\n",
    ")\n",
    "\n",
    "df.index.name = 'doc-id'\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>am</th>\n",
       "      <th>del</th>\n",
       "      <th>hap</th>\n",
       "      <th>i a</th>\n",
       "      <th>not</th>\n",
       "      <th>was</th>\n",
       "      <th>, i</th>\n",
       "      <th>am h</th>\n",
       "      <th>am n</th>\n",
       "      <th>appy</th>\n",
       "      <th>...</th>\n",
       "      <th>not</th>\n",
       "      <th>ot d</th>\n",
       "      <th>ot h</th>\n",
       "      <th>s de</th>\n",
       "      <th>s no</th>\n",
       "      <th>t de</th>\n",
       "      <th>t ha</th>\n",
       "      <th>t wa</th>\n",
       "      <th>was</th>\n",
       "      <th>yed,</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>doc-id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>2 rows × 37 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "         am    del   hap   i a   not   was  , i   am h  am n  appy  ...  not   \\\n",
       "doc-id                                                              ...         \n",
       "0          1     1     1     1     1     1     1     0     1     1  ...     1   \n",
       "1          1     1     1     1     1     1     1     1     0     1  ...     1   \n",
       "\n",
       "        ot d  ot h  s de  s no  t de  t ha  t wa  was   yed,  \n",
       "doc-id                                                        \n",
       "0          0     1     1     0     0     1     1     1     1  \n",
       "1          1     0     0     1     1     0     1     1     1  \n",
       "\n",
       "[2 rows x 37 columns]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.feature_extraction.text import CountVectorizer\n",
    "\n",
    "vec = CountVectorizer(analyzer='char', ngram_range=(4,4))\n",
    "\n",
    "x = vec.fit_transform(flight_delayed_lines)\n",
    "\n",
    "df = pd.DataFrame(\n",
    "    x.todense(), \n",
    "    columns=vec.get_feature_names(),\n",
    ")\n",
    "\n",
    "df.index.name = 'doc-id'\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "lines_fruits = [\n",
    "    'I like apples',\n",
    "    'I like oranges',\n",
    "    'I like pears',\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "from IPython.display import display_html\n",
    "\n",
    "def display_side_by_side(*args):\n",
    "    \n",
    "    html_str=''\n",
    "    \n",
    "    for df in args:\n",
    "        html_str += df.to_html()\n",
    "        html_str += ''.join(['&nbsp;' for i in range(20)])\n",
    "       \n",
    "    html_str = html_str.replace('table','table style=\"display:inline;\"')\n",
    "    \n",
    "    display_html(html_str, raw=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table style=\"display:inline;\" border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>apples</th>\n",
       "      <th>i</th>\n",
       "      <th>like</th>\n",
       "      <th>oranges</th>\n",
       "      <th>pears</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CountVectorizer</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table style=\"display:inline;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<table style=\"display:inline;\" border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>apples</th>\n",
       "      <th>i</th>\n",
       "      <th>like</th>\n",
       "      <th>oranges</th>\n",
       "      <th>pears</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TfidfVectorizer</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.77</td>\n",
       "      <td>0.45</td>\n",
       "      <td>0.45</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.00</td>\n",
       "      <td>0.45</td>\n",
       "      <td>0.45</td>\n",
       "      <td>0.77</td>\n",
       "      <td>0.00</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.00</td>\n",
       "      <td>0.45</td>\n",
       "      <td>0.45</td>\n",
       "      <td>0.00</td>\n",
       "      <td>0.77</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table style=\"display:inline;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from sklearn.feature_extraction.text import CountVectorizer\n",
    "\n",
    "vec = CountVectorizer(token_pattern=r'\\w+')\n",
    "\n",
    "x = vec.fit_transform(lines_fruits)\n",
    "\n",
    "df1 = pd.DataFrame(\n",
    "    x.todense().astype(float).round(2), \n",
    "    columns=vec.get_feature_names(),\n",
    ")\n",
    "\n",
    "df1.index.name = 'CountVectorizer'\n",
    "\n",
    "from sklearn.feature_extraction.text import TfidfVectorizer\n",
    "\n",
    "vec = TfidfVectorizer(token_pattern=r'\\w+')\n",
    "\n",
    "x = vec.fit_transform(lines_fruits)\n",
    "\n",
    "df2 = pd.DataFrame(\n",
    "    x.todense().round(2), \n",
    "    columns=vec.get_feature_names(),\n",
    ")\n",
    "\n",
    "df2.index.name = 'TfidfVectorizer'\n",
    "\n",
    "\n",
    "display_side_by_side(df1, df2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>apples</th>\n",
       "      <th>i</th>\n",
       "      <th>like</th>\n",
       "      <th>oranges</th>\n",
       "      <th>pears</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CountVectorizer</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>1.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                 apples    i  like  oranges  pears\n",
       "CountVectorizer                                   \n",
       "0                   1.0  1.0   1.0      0.0    0.0\n",
       "1                   0.0  1.0   1.0      1.0    0.0"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.feature_extraction.text import CountVectorizer\n",
    "\n",
    "vec = CountVectorizer(token_pattern=r'\\w+')\n",
    "\n",
    "x = vec.fit_transform(lines_fruits)\n",
    "\n",
    "df1 = pd.DataFrame(\n",
    "    x.todense().astype(float).round(2), \n",
    "    columns=vec.get_feature_names(),\n",
    ")\n",
    "\n",
    "df1.index.name = 'CountVectorizer'\n",
    "\n",
    "df1.head(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>apples</th>\n",
       "      <th>i</th>\n",
       "      <th>like</th>\n",
       "      <th>oranges</th>\n",
       "      <th>pears</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>doc-id</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.767495</td>\n",
       "      <td>0.453295</td>\n",
       "      <td>0.453295</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.453295</td>\n",
       "      <td>0.453295</td>\n",
       "      <td>0.767495</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.453295</td>\n",
       "      <td>0.453295</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.767495</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "          apples         i      like   oranges     pears\n",
       "doc-id                                                  \n",
       "0       0.767495  0.453295  0.453295  0.000000  0.000000\n",
       "1       0.000000  0.453295  0.453295  0.767495  0.000000\n",
       "2       0.000000  0.453295  0.453295  0.000000  0.767495"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.feature_extraction.text import TfidfVectorizer\n",
    "\n",
    "vec = TfidfVectorizer(token_pattern=r'\\w+')\n",
    "\n",
    "x = vec.fit_transform(lines_fruits)\n",
    "\n",
    "df = pd.DataFrame(\n",
    "    x.todense(), \n",
    "    columns=vec.get_feature_names(),\n",
    ")\n",
    "\n",
    "df.index.name = 'doc-id'\n",
    "\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [],
   "source": [
    "import spacy\n",
    "\n",
    "nlp = spacy.load('en_core_web_md')\n",
    "\n",
    "\n",
    "terms = ['I', 'like', 'apples', 'oranges', 'pears']\n",
    "vectors = [\n",
    "    nlp(term).vector.tolist() for term in terms\n",
    "]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "300"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(vectors[terms.index('apples')])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     -0.633400\n",
       "1      0.189810\n",
       "2     -0.535440\n",
       "3     -0.526580\n",
       "4     -0.300010\n",
       "         ...   \n",
       "295    0.068773\n",
       "296   -0.238810\n",
       "297   -1.178400\n",
       "298    0.255040\n",
       "299    0.611710\n",
       "Name: apples, Length: 300, dtype: float64"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Series(vectors[terms.index('apples')]).rename('apples')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>I</th>\n",
       "      <th>like</th>\n",
       "      <th>apples</th>\n",
       "      <th>oranges</th>\n",
       "      <th>pears</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>I</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.444509</td>\n",
       "      <td>0.795573</td>\n",
       "      <td>0.811759</td>\n",
       "      <td>0.795573</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>like</th>\n",
       "      <td>0.444509</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.670129</td>\n",
       "      <td>0.722825</td>\n",
       "      <td>0.670129</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>apples</th>\n",
       "      <td>0.795573</td>\n",
       "      <td>0.670129</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.221906</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>oranges</th>\n",
       "      <td>0.811759</td>\n",
       "      <td>0.722825</td>\n",
       "      <td>0.221906</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.221906</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>pears</th>\n",
       "      <td>0.795573</td>\n",
       "      <td>0.670129</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>0.221906</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                I      like    apples   oranges     pears\n",
       "I        0.000000  0.444509  0.795573  0.811759  0.795573\n",
       "like     0.444509  0.000000  0.670129  0.722825  0.670129\n",
       "apples   0.795573  0.670129  0.000000  0.221906  0.000000\n",
       "oranges  0.811759  0.722825  0.221906  0.000000  0.221906\n",
       "pears    0.795573  0.670129  0.000000  0.221906  0.000000"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "from sklearn.metrics.pairwise import cosine_similarity\n",
    "from sklearn.metrics.pairwise import cosine_distances\n",
    "\n",
    "pd.DataFrame(\n",
    "    cosine_distances(vectors),\n",
    "    index=terms,\n",
    "    columns=terms,\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style  type=\"text/css\" >\n",
       "    #T_66f5453a_c5cc_11ea_af7d_784f43517922row0_col0 {\n",
       "            background-color:  #808080;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row0_col1 {\n",
       "            background-color:  #c6c6c6;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row0_col2 {\n",
       "            background-color:  #f2f2f2;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row0_col3 {\n",
       "            background-color:  #f2f2f2;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row0_col4 {\n",
       "            background-color:  #f2f2f2;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row1_col0 {\n",
       "            background-color:  #bebebe;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row1_col1 {\n",
       "            background-color:  #808080;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row1_col2 {\n",
       "            background-color:  #e0e0e0;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row1_col3 {\n",
       "            background-color:  #e6e6e6;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row1_col4 {\n",
       "            background-color:  #e0e0e0;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row2_col0 {\n",
       "            background-color:  #f1f1f1;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row2_col1 {\n",
       "            background-color:  #ebebeb;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row2_col2 {\n",
       "            background-color:  #808080;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row2_col3 {\n",
       "            background-color:  #9f9f9f;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row2_col4 {\n",
       "            background-color:  #808080;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row3_col0 {\n",
       "            background-color:  #f2f2f2;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row3_col1 {\n",
       "            background-color:  #f2f2f2;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row3_col2 {\n",
       "            background-color:  #9f9f9f;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row3_col3 {\n",
       "            background-color:  #808080;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row3_col4 {\n",
       "            background-color:  #9f9f9f;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row4_col0 {\n",
       "            background-color:  #f1f1f1;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row4_col1 {\n",
       "            background-color:  #ebebeb;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row4_col2 {\n",
       "            background-color:  #808080;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row4_col3 {\n",
       "            background-color:  #9f9f9f;\n",
       "            color:  #000000;\n",
       "        }    #T_66f5453a_c5cc_11ea_af7d_784f43517922row4_col4 {\n",
       "            background-color:  #808080;\n",
       "            color:  #000000;\n",
       "        }</style><table id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922\" ><thead>    <tr>        <th class=\"blank level0\" ></th>        <th class=\"col_heading level0 col0\" >I</th>        <th class=\"col_heading level0 col1\" >like</th>        <th class=\"col_heading level0 col2\" >apples</th>        <th class=\"col_heading level0 col3\" >oranges</th>        <th class=\"col_heading level0 col4\" >pears</th>    </tr></thead><tbody>\n",
       "                <tr>\n",
       "                        <th id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922level0_row0\" class=\"row_heading level0 row0\" >I</th>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row0_col0\" class=\"data row0 col0\" >1</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row0_col1\" class=\"data row0 col1\" >0.56</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row0_col2\" class=\"data row0 col2\" >0.2</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row0_col3\" class=\"data row0 col3\" >0.19</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row0_col4\" class=\"data row0 col4\" >0.2</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922level0_row1\" class=\"row_heading level0 row1\" >like</th>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row1_col0\" class=\"data row1 col0\" >0.56</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row1_col1\" class=\"data row1 col1\" >1</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row1_col2\" class=\"data row1 col2\" >0.33</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row1_col3\" class=\"data row1 col3\" >0.28</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row1_col4\" class=\"data row1 col4\" >0.33</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922level0_row2\" class=\"row_heading level0 row2\" >apples</th>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row2_col0\" class=\"data row2 col0\" >0.2</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row2_col1\" class=\"data row2 col1\" >0.33</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row2_col2\" class=\"data row2 col2\" >1</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row2_col3\" class=\"data row2 col3\" >0.78</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row2_col4\" class=\"data row2 col4\" >1</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922level0_row3\" class=\"row_heading level0 row3\" >oranges</th>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row3_col0\" class=\"data row3 col0\" >0.19</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row3_col1\" class=\"data row3 col1\" >0.28</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row3_col2\" class=\"data row3 col2\" >0.78</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row3_col3\" class=\"data row3 col3\" >1</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row3_col4\" class=\"data row3 col4\" >0.78</td>\n",
       "            </tr>\n",
       "            <tr>\n",
       "                        <th id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922level0_row4\" class=\"row_heading level0 row4\" >pears</th>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row4_col0\" class=\"data row4 col0\" >0.2</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row4_col1\" class=\"data row4 col1\" >0.33</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row4_col2\" class=\"data row4 col2\" >1</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row4_col3\" class=\"data row4 col3\" >0.78</td>\n",
       "                        <td id=\"T_66f5453a_c5cc_11ea_af7d_784f43517922row4_col4\" class=\"data row4 col4\" >1</td>\n",
       "            </tr>\n",
       "    </tbody></table>"
      ],
      "text/plain": [
       "<pandas.io.formats.style.Styler at 0x7fd8ff211860>"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import seaborn as sns\n",
    "from sklearn.metrics.pairwise import cosine_similarity\n",
    "\n",
    "cm = sns.light_palette(\"Gray\", as_cmap=True)\n",
    "\n",
    "pd.DataFrame(\n",
    "    cosine_similarity(vectors),\n",
    "    index=terms,\n",
    "    columns=terms,\n",
    ").round(2).style.background_gradient(cmap=cm)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
